

#include "task_dev_reset.h"
#include "comm_utils.h"

DevResetTask::DevResetTask(EvSerial *serial, int ms)
    : TaskCommBase(serial)
{
    timeout_ms = ms;
}

void DevResetTask::run()
{
    QString mssg = QString("复位设备...");
    emit messageLogged(LogUtils::makeLogBin(mssg));

    int ret = callReset(timeout_ms);
    if (ret != 0) {
        mssg = QString("复位设备失败, 错误码: %1").arg(ret);
        emit messageLogged(LogUtils::makeLogBin(mssg));
        emit finished(false);
    } else {
        emit messageLogged(LogUtils::makeLogBin("复位设备成功"));
        emit finished(true);
    }
}
